using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Xml;
using System.Xml.XPath;
// Librairie Personnelle
using ShareResources.Xml;

using LibrairieBahaMen.Xml;

namespace EasySeries.Dal.HandlerXml
{
    class Check_Delay_Handler : Handler
    {

        public IList<Object> Get()
        {
            IList<Object> l_ob = new List<Object>();
            int res = 0;
            XPathNodeIterator x_nit = XmlUtil.CreateIteratorQuery("prefs.xml", "/prefs/update");
            while (x_nit.MoveNext())
                res += int.Parse(x_nit.Current.Value);

            Update u = new Update(res);
            l_ob.Add((Object)u);
            
            return l_ob;
        }

        public void Add(Object o) { }

        public void Remove(Object o) {}

        public void Update(Object old,Object new_u)
        {
            XmlDocument root = XmlUtil.CreateDocument(AbonnementHandler.FILE_ABONNEMENT);
            XmlNode xn = root.FirstChild;
            while (xn.NextSibling != null)
            {
                XmlNode c_xn = xn.FirstChild;
                while (c_xn.NextSibling != null)
                {
                    if (c_xn.Name == "seconds")
                        c_xn.InnerText = ((Update)new_u).Seconds.ToString();

                    c_xn = c_xn.NextSibling;
                }
                xn = xn.NextSibling;
            }
        }

    }
}
